package com.shop.advertisement.controller;

import com.shop.advertisement.service.IndexSlideAdService;
import com.shop.pojo.LdbzIndexSlideAd;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/index/slide/ad/")
public class IndexSlideAdController {
    private static final Logger logger = LoggerFactory.getLogger(IndexSlideAdController.class);
    @Autowired
    private IndexSlideAdService indexSlideAdService;

    @RequestMapping(value = "/getIndexSlideAdPage", method = RequestMethod.GET)
    public List<LdbzIndexSlideAd> getIndexSlideAdPage(@RequestParam(value = "entity") LdbzIndexSlideAd entity, @RequestParam(value = "start") int start, @RequestParam("limit") int limit) {
        return indexSlideAdService.getIndexSlideAdPage(entity, start, limit);
    }

    @RequestMapping(value = "/countByEntity", method = RequestMethod.GET)
    public long countByEntity(@RequestParam(value = "entity") LdbzIndexSlideAd entity) {
        return indexSlideAdService.countByEntity(entity);
    }

    @RequestMapping(value = "/selectByKey/{id}", method = RequestMethod.GET)
    public LdbzIndexSlideAd selectByKey(@RequestParam("id") Long id) {
        return indexSlideAdService.selectByKey(id);
    }

    @RequestMapping(value = "/deleteByKey/{id}", method = RequestMethod.GET)
    public int deleteByKey(@RequestParam("id") Long id) {
        return indexSlideAdService.deleteByKey(id);
    }

    @RequestMapping(value = "/deleteByKeys/{ids}", method = RequestMethod.GET)
    public int deleteByKeys(@RequestParam("ids") List<Long> ids) {
        return indexSlideAdService.deleteByKeys(ids);
    }

    @RequestMapping(value = "/insertByEntity", method = RequestMethod.GET)
    public int insertByEntity(@RequestParam("entity") LdbzIndexSlideAd entity) {
        return indexSlideAdService.insertByEntity(entity);
    }

    @RequestMapping(value = "/updateByKey", method = RequestMethod.GET)
    public int updateByKey(@RequestParam("entity") LdbzIndexSlideAd entity) {
        return indexSlideAdService.updateByKey(entity);
    }

    @RequestMapping(value = "/getIndexSlideAdByRedis")
    public List<LdbzIndexSlideAd> getIndexSlideAdByRedis() {
        return indexSlideAdService.getIndexSlideAdByRedis();
    }
}
